
#include <iostream>

using namespace std;

class Solution
{
    public:
        int strStr(string haystack, string needle) 
        {
            int n = haystack.size(), m = needle.size();
            for (int i = 0; i + m <= n; i++) 
            {
                bool flag = true;
                for (int j = 0; j < m; j++) 
                {
                    if (haystack[i + j] != needle[j]) 
                    {
                        flag = false;
                        break;
                    }
                }
                if (flag) 
                {
                    return i;
                }
            }
            return -1;
        }
};

int main()
{
    Solution s;
    int ret =  s.strStr("leetcode","code");
    cout << ret << endl;
    return 0;
}
